package com.mdl.springmvc.tpg.controller;

import com.mdl.springmvc.tpg.po.TpgBzxm;
import com.mdl.springmvc.tpg.po.TpgFyxx;
import com.mdl.springmvc.tpg.po.TpgJtcyxx;
import com.mdl.springmvc.tpg.service.TpgBzxmService;
import com.mdl.springmvc.tpg.service.TpgFyxxService;
import com.mdl.springmvc.tpg.service.TpgJtcyxxService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

/**
 * @Desc
 * @Author madengling
 * @Time 2020/10/29 10:04
 */
@Controller
public class InsertController {
    private static Logger logger = Logger.getLogger(InsertController.class);
    @Autowired
    private TpgBzxmService bzxmService;
    @Autowired
    private TpgFyxxService fyxxService;
    @Autowired
    private TpgJtcyxxService jtcyxxService;

    @RequestMapping(value = "/insert_mysql")
    public Map insertMysql(Integer num){
        Map<String,Object> map = new HashMap<>();
        List<TpgBzxm> bzxms = new ArrayList<>();
        for(int i=0;i<num;i++){
            TpgBzxm bzxm = new TpgBzxm();
            bzxm.setId((long) i);
            bzxm.setCode((long) i);
            bzxm.setXmmc("项目名称"+i);
            bzxms.add(bzxm);
        }
        bzxmService.insertTpgBzxm(bzxms);
        List<TpgFyxx> fyxxs = new ArrayList<>();
        for(int i=0;i<num;i++){
            TpgFyxx fyxx = new TpgFyxx();
            fyxx.setId((long) i);
            fyxx.setCode((long) i);
            fyxx.setFwzl("房屋坐落"+i);
            fyxxs.add(fyxx);
        }
        fyxxService.insertTpgFyx(fyxxs);
        List<TpgJtcyxx> jtcyxxes = new ArrayList<>();
        for(int i=0;i<num;i++){
            TpgJtcyxx jtcyxx = new TpgJtcyxx();
            jtcyxx.setId((long) i);
            jtcyxx.setCjsj(new Date());
            jtcyxx.setXm("成员"+i);
            jtcyxxes.add(jtcyxx);
        }
        jtcyxxService.insertTpgJtcyxx(jtcyxxes);
        map.put("success",true);
        return map;
    }
}
